﻿using System.Collections.Generic;
using System.Dynamic;

using zijian666.Converts.Abstractions;
using zijian666.Converts.Convertor.Base;
using zijian666.Converts.Core;

namespace zijian666.Converts.Dynamic;

/// <summary>
/// 动态类型转换器
/// </summary>
public class DynamicObjectConvertor : AllowNullConvertor<DynamicObject>
    , IFrom<object, DynamicObject>
    , IFrom<object[], DynamicObject>
    , IFrom<Dictionary<string, object>, DynamicObject>
{
    /// <inheritdoc/>
    public ConvertResult<DynamicObject> From(IConvertContext context, object input)
        => DynamicFactory.Create(input, context.Settings);

    /// <inheritdoc/>
    public ConvertResult<DynamicObject> From(IConvertContext context, Dictionary<string, object> input)
        => DynamicFactory.Create(input, context.Settings);

    /// <inheritdoc/>
    public ConvertResult<DynamicObject> From(IConvertContext context, object[] input)
        => DynamicFactory.Create(input, context.Settings);
}
